"""
邮箱人员设置  mis 中获取
"""
from report_system.utils import db_util


def dz_mails():
    """
    获取店长邮箱
    :return:
    """
    dz_mails_sql = """
            SELECT 
            concat('[',group_concat( distinct '"',city.short_name,'"'),']') 城市,
            uoa.area_id 城市id,
            group_concat(distinct uo.name) 组织 ,
            uo1.name 组织2 ,
            users.realname 姓名,
            users.email 邮箱,
            uo.type   -- `type` smallint(6) DEFAULT NULL COMMENT '组织类型（10总部，20城市，30大区，40BD群，50站）',
            FROM  youjia.user_org uo  
            LEFT JOIN youjia.user_org uo1 ON uo1.id = uo.parent_id
            LEFT JOIN youjia.user_org_area uoa on uoa.org_id = uo1.id and uoa.type = 1
            LEFT JOIN youjia.city on city.id = uoa.area_id
            left join youjia.user_org_role uor on uor.org_id=uo.id and uor.role_id=73
            left join youjia.users on users.id=uor.user_id
            WHERE city.id <> 376
            and uo.type = 50
            and users.id IS NOT NULL
            and users.email is not null
            and users.is_frozen = 0
            and uor.is_delete = 0
            GROUP BY users.id;
         """
    return db_util.records_select(dz_mails_sql)


def qz_mails():
    """
    获取区总邮箱
    :return:
    """
    dz_mails_sql = """
            SELECT 
            concat('[',group_concat( distinct '"',city.short_name,'"'),']') 城市,
            uoa.area_id 城市id,
            group_concat(distinct uo.name) 组织 ,
            uo1.name 组织2 ,
            users.realname 姓名,
            users.email 邮箱,
            uo.type   -- `type` smallint(6) DEFAULT NULL COMMENT '组织类型（10总部，20城市，30大区，40BD群，50站）',
            FROM  youjia.user_org uo  
            LEFT JOIN youjia.user_org uo1 ON uo1.id = uo.parent_id
            LEFT JOIN youjia.user_org_area uoa on uoa.org_id = uo1.id and uoa.type = 1
            LEFT JOIN youjia.city on city.id = uoa.area_id
            left join youjia.user_org_role uor on uor.org_id=uo.id and uor.role_id=73
            left join youjia.users on users.id=uor.user_id
            WHERE city.id <> 376
            and uo.type = 50
            and users.id IS NOT NULL
            and users.email is not null
            and users.is_frozen = 0
            and uor.is_delete = 0
            GROUP BY users.id;
         """
    return db_util.records_select(dz_mails_sql)


# 区总

mail_qz = {  # 区总
    # 'zhangsen@iyoujia.com': ('杭州', '苏州', '南京', '郑州', '上海', '武汉'),
    # 宿迁

    'lizhenxing@iyoujia.com': ('太原', '西安'),

    # 见习
    'tangdou@iyoujia.com;zhanglin@iyoujia.com': '贵阳',
    'wangbo@iyoujia.com;kongyuepeng@iyoujia.com;huxiupeng@iyoujia.com': '南京',
    'zhanglin@iyoujia.com': '青岛',
    'oumingsong@iyoujia.com': ('上海', '厦门', '重庆'),
    # 储备
    'jiangxudong@iyoujia.com;yangzhijun@iyoujia.com;': '成都',
    'zengxueqin@iyoujia.com': ('广州', '珠海'),
    'huxiaoyun@iyoujia.com': '昆明',
    'chensimin@iyoujia.com': ('长沙', '厦门', '珠海'),
    # 合并之后变更
    'wuqiang@city-home.cn': ('上海', '苏州', '杭州', '宁波', '绍兴'),
    'zhangsen@iyoujia.com': ('北京', '天津', '淮安', '大连', '承德', '南京', '扬州', '镇江', '合肥', '宿迁'),
    'lichan@city-home.cn': ('广州', '深圳', '珠海', '三亚', '厦门', '海口'),
    'liupeiyu@city-home.cn': ('武汉', '长沙', '桂林', '南宁', '北海','青岛', '济南', '威海', '郑州', '西安', '太原'),
    # 'mozhengrong@city-home.cn': ('重庆', '成都', '阆中', '西昌', '贵阳', '昆明'),
    'mozhengrong@city-home.cn': ('重庆', '成都', '贵阳', '昆明', '南充', '凉山'),
}
# 店长
mails_dz = {'fengnannan@iyoujia.com;wangbo1@iyoujia.com': ['广州'],
            'liuxi@iyoujia.com;zhangyingjing@iyoujia.com;yangzhijun@iyoujia.com': ['成都'],
            'tongkelei@iyoujia.com': ['杭州'],

            'zhanglin@iyoujia.com;': ['青岛'],
            'leixuelong@iyoujia.com;': ['三亚', '珠海'],
            # 'zhangtuorui@iyoujia.com;': ['西安'],
            'muluyue@iyoujia.com;': ['天津'],
            'wanghongqiang@iyoujia.com': ['太原'],
            'yangzhiqiang@iyoujia.com': ['厦门'],
            'shenchuan@iyoujia.com;': ['苏州'],
            # 'xiechao@iyoujia.com': ['长沙'],
            'chenshunming@iyoujia.com': ['武汉'],
            'chentianxian@iyoujia.com': ['南京'],
            'xingxu@iyoujia.com': ['郑州', '长沙'],
            'yanghui@iyoujia.com;': ['贵阳']}

mails_city = {  # 苏州
    'caopeng@iyoujia.com;changxiaoxu@iyoujia.com;liwansu@iyoujia.com;'
    'shaoqinyun@iyoujia.com;lishuangcai@iyoujia.com;yuanqiuli@iyoujia.com;chengyugui@iyoujia.com;'
    'wanghongwei@iyoujia.com;sunyuxuan@iyoujia.com;liuxiangzi@iyoujia.com;'
    'yanlina@iyoujia.com;liujianxin@iyoujia.com;tanglei@iyoujia.com;weidong@city-home.cn': ['苏州'],
    # 成都
    'yinqiaoli@iyoujia.com;wanqingqing@iyoujia.com;zhangyi@iyoujia.com;zhouguoqiang@iyoujia.com;'
    'shenhong@iyoujia.com;zhoujingjing@iyoujia.com;zhaopengcheng@iyoujia.com;yanyue@iyoujia.com;luosong@iyoujia.com;'
    'chenxiao@iyoujia.com;pengjing@iyoujia.com;zhangyi@iyoujia.com;chengqiang@iyoujia.com;tangting@iyoujia.com;'
    'lizhen@iyoujia.com;wangtao@iyoujia.com;gaoqinwen@city-home.cn': ['成都'],
    'chenjingyi@iyoujia.com;zhouzhuo@iyoujia.com': ['珠海'],
    # 重庆
    'gaokuan@iyoujia.com;zhaokaiyu@iyoujia.com;pubaolin@iyoujia.com;liujing@iyoujia.com;'
    'zhangyuan@iyoujia.com;zhangjingyu@iyoujia.com;zhouhongling@iyoujia.com;chengken@iyoujia.com;liutao@iyoujia.com;'
    'jianghong@city-home.cn;chenshiyu@city-home.cn;yangqin@iyoujia.com;zhangyue@iyoujia.com;tanmingyue@iyoujia.com': ['重庆'],
    # 杭州
    'yaoyuzhong@iyoujia.com;tongkelei@iyoujia.com;jiangjiani@iyoujia.com': ['杭州'],
    # 南京
    'guoxiaoqin@iyoujia.com;wangying@iyoujia.com;jingman@iyoujia.com;xiazhiyuan@iyoujia.com;zhangzhenyu@iyoujia.com;'
    'yurongjie@iyoujia.com': ['南京'],
    # 广州
    'linzeyu@iyoujia.com;zengjunqing@iyoujia.com;qiusiping@iyoujia.com;longjintong@iyoujia.com;'
    'oushuai@iyoujia.com;yuzhijie@iyoujia.com;chenjinyi@iyoujia.com'
    ';yichuangjia@iyoujia.com;zhangyanchun@iyoujia.com;shenxinjie@iyoujia.com;liusimeng@iyoujia.com;'
    'zhuanglinyi@city-home.cn': ['广州'],
    # 上海
    'liweifeng@iyoujia.com;liuyuan@iyoujia.com;wangzhenglan@iyoujia.com;liuchunyu@iyoujia.com;'
    'baojun@iyoujia.com;zhangjunwei@iyoujia.com;huangdajie@iyoujia.com;'
    'gaoqiang@iyoujia.com': ['上海'],
    # 昆明
    'shiyi@iyoujia.com;liyunxiang@iyoujia.com;qianxingyu@iyoujia.com;'
    'yandetao@iyoujia.com;wangbing@iyoujia.com;luxin@iyoujia.com': ['昆明'],
    # 太原
    'guoyu@iyoujia.com;wuyuting@iyoujia.com;majinbin@iyoujia.com;huashaokang@iyoujia.com;fanyu@iyoujia.com;'
    'huqizhang@iyoujia.com;wangting@iyoujia.com;lipengrui@iyoujia.com': ['太原'],
    # 青岛
    'zhanglin@iyoujia.com': ['青岛'],
    # 北京
    'wangshaodong@iyoujia.com;shenxinjie@iyoujia.com;liusimeng@iyoujia.com;wangyajun@city-home.cn;'
    'liying2@city-home.cn': ['北京'],
    # 长沙
    'wuqing@iyoujia.com;lizhifei@iyoujia.com': ['长沙'],
    # 贵阳
    'fanchenyang@iyoujia.com;zhangtingting@iyoujia.com;kongyuepeng@iyoujia.com;chenmin@iyoujia.com;gaoshan@city-home.cn': ['贵阳'],
    # 厦门
    'chenxiaojun@iyoujia.com;linlijuan@iyoujia.com;hechuang@iyoujia.com': ['厦门'],
    # 天津
    'muluyue@iyoujia.com;zhangziqi@iyoujia.com;yanglianshuo@iyoujia.com;tangqianqian@iyoujia.com;'
    'muluyue@iyoujia.com;liuzhe@city-home.cn': ['天津'],
    'fengxiaoqi@city-home.cn': ['合肥'],
    # 武汉
    # 'libo@iyoujia.com': ['武汉'],
    # 西安
    'zhangli@iyoujia.com;caojialin@iyoujia.com;duzhixiong@iyoujia.com;'
    'aoxin@iyoujia.com;huyanchao@iyoujia.com;zhangyong1@iyoujia.com;'
    'heyuhua@iyoujia.com;zhibin@iyoujia.com;lvpengtao@city-home.cn;'
    'liumengfei@city-home.cn;lizhenxing@iyoujia.com': ['西安'],
    # 三亚
    'weiwanzhen@iyoujia.com;huangchen@iyoujia.com;guoyue@iyoujia.com': ['三亚'],
    "xukaiyang@city-home.cn": ["淮安", "扬州", "镇江"],
    "wangchao@city-home.cn;fengxiaoqi@city-home.cn;chentianxian@iyoujia.com;kongyuepeng@iyoujia.com": ["南京"],
    "xixiongli@city-home.cn;zhangxiaohao@city-home.cn": ["济南", "青岛", "威海"],
    "lizhenxing@iyoujia.com": ["太原"],
    "lichengli@city-home.cn": ["郑州"],
    "wangzhe@city-home.cn;tongkelei@iyoujia.com": ["杭州"],
    "liubingyou@city-home.cn": ["宁波"],
    "liujiantao@iyoujia.com;hujiayun@city-home.cn;leiyuxin@city-home.cn": ["上海"],
    "shenchuan@iyoujia.com": ["苏州"],
    "zhuanglinyi@city-home.cn;zengxueqin@iyoujia.com": ["广州"],
    "leixuelong@iyoujia.com": ["海口", "三亚"],
    "yangzhiqiang@iyoujia.com": ["厦门"],
    "zhangxu@city-home.cn;xuxinyuan@city-home.cn": ["深圳"],
    "wangxiaolong@city-home.cn": ["桂林"],
    "wangbin@city-home.cn": ["南宁"],
    "chensi@city-home.cn;chenshunming@iyoujia.com": ["武汉"],
    "wangbin@city-home.cn;liujie@city-home.cn": ["长沙"],
    "gaoqinwen@city-home.cn;liuxi@iyoujia.com": ["成都"],
    "liaoguochun@city-home.cn;huxiaoyun@iyoujia.com": ["昆明"],
    "jianghong@city-home.cn;chenshiyu@city-home.cn;oumingsong@iyoujia.com": ["重庆"]
}
mails_all = dict()
mails_all.update(mail_qz)
mails_all.update(mails_dz)
mails_all.update(mails_city)

mails_invest = {
    '375740038@qq.com': ['刘祥春'],
    '1040984900@qq.com': ['莫莉莉'],
    '715239268@qq.com': ['彭晓汛'],
    '40853238@qq.com': ['谢翻生'],
    '1974559254@qq.com': ['张春霞'],
    'qing_sheng@sina.com ': ['盛晴'],
    '1062476232@qq.com': ['张水生'],
    '171449750@qq.com': ['李小倩'],
    '466675515@qq.com': ['王春霞'],
    '176555515@qq.com ': ['房苏阳'],
    'liangchengchun@163.com': ['梁成春'],
    '14416171@qq.com': ['许晶蕾'],
    '123760363@qq.com': ['潘敬'],
    '304318877@qq.com': ['汪绍伟'],
    '727028762@qq.com': ['林伟坤'],
    '13439696888@139.com': ['徐海辉'],
    '13321100029@163.com': ['白宁'],
    '343185@qq.com': ['金炜东'],
    '755032012@qq.com': ['邹军'],
    '867980842@qq.com': ['刘胜全'],
    '15802912567@163.com': ['程凤选'],
    '2382102984@qq.com': ['雷正'],
    '1054979996@qq.com': ['王宏霞'],
    '47530699@qq.com': ['姜赖'],
    '280565852@qq.com': ['刘忠贵'],
    '1549287969@qq.com': ['屈玲'],
    '3517239879@qq.com': ['董志伟'],
    '13819169258@139.com': ['王华'],
    '1033200192@qq.com': ['徐国江'],
    '583157426@qq.com': ['唐昊'],
    '466598801@qq.com': ['林勇'],
    'xielinghong2006071@163.com': ['谢玲红'],
    'huangzhimin519@vip.163.com': ['张青'],
    '392335871@qq.com': ['姚发金'],
    '13301096448@163.com': ['钱广林'],
    '13940919819@139.com': ['刘元庄'],
    'gaofeng-nycp@126.com': ['高峰'],
    'ygllyy@126.com': ['杨光'],
    'gzy0931@126.com': ['高志瑛'],
    'wsqkj@sina.com': ['钱可军'],
    '519669838@qq.com': ['张林节'],
    '452591276@qq.com': ['郑华兴'],
    '404120523@qq.com': ['高广滨'],
    '1755478606@qq.com': ['侯雪梅'],
    '878785906@qq.com': ['王雷鑫'],
    '122413143@qq.com': ['邢星星'],
    'ajaxchen@163.com': ['陈汝皓'],
    'ym@jtt555.com': ['鄢敏'],
    '360341660@qq.com': ['黄大明'],
    '2064942061@qq.com': ['宁洪伟'],
    '33211656@qq.com': ['吕东兴'],
    'cailancheng@126.com': ['蔡兰成'],
    '550851227@qq.com': ['马亚妮'],
    '649570385@qq.com': ['秦玉桂'],
    'Sh_kebang@163.com': ['李武邦'],
    'wanhong_112@163.com': ['万宏'],
    'wy13072299000@126.com': ['王媛'],
    '891360359@qq.com': ['杨美荣'],
    'djl_djl@sina.com': ['丁俊龙'],
    '33573617@qq.com': ['郭岩'],
    '970146040@qq.com': ['王巨霞'],
    'lawyerd69@126.com': ['邓永军'],
    '13753157907@139.com': ['董祯慧'],
    '377509093@qq.com': ['刘锐'],
    '123441909@qq.com': ['罗绍鑫'],
    '310371758@qq.com': ['盛益'],
    '13501606812@163.com': ['李敏'],
    'wanghb1972@163.com': ['王洪宾'],
    '13181988198@163.com': ['刘海涛'],
    'linbohit@163.com': ['于圆圆'],
    'wzzpiano@163.com': ['张廷功'],
    '863668017@qq.com': ['鄢晓刚'],
    'lzy51@sohu.com': ['鲁爽'],
    '694989011@qq.com': ['崔然然'],
    '584489024@qq.com': ['朱英玉'],
    'hhy9399@163.com': ['黄海英'],
    '26301496@qq.com': ['耿一博'],
    '277947757@qq.com': ['王刚'],
    'liyang08@corp.netease.com': ['网易严选'],
    '2041632@qq.com': ['赵灏'],
    'xiehuilkm@163.com': ['卢凯民'],
    '1466082158@qq.com': ['赵忱'],
    '656719219@qq.com': ['陈仁超'],
    'zhujj@eminns.com': ['祝海涵'],
    '188819385@qq.com': ['陆健'],
    '455656581@qq.com': ['陈思达'],
    'wzxzlywzxzly@163.com': ['郭广立'],
    '505136852@qq.com': ['袁雯琦'],
    '3773490@qq.com': ['宗军'],
    '1251604068@qq.com': ['王琪'],
    '492175306@qq.com': ['谷艳'],
    '562927468@qq.com': ['王炜'],
    'wjy5898@163.com': ['魏锦轶'],
    '984662080@qq.com': ['黄谋晓'],
    '38055468@qq.com': ['宋晗'],
    'zzxxhh126@126.com': ['张晓辉'],
    'mengxianyue@126.com': ['吴宇桐'],
    '749016069@qq.com': ['孙建峰'],
    '70995133@qq.com': ['周振宇'],
    'hysshiqiang@163.com': ['史强'],
    '0546wenmin@163.com': ['孙文民'],
    '237271@qq.com': ['李泳进'],
    '361397533@qq.com': ['魏景宇'],
    '644949047@qq.com': ['云中侠'],
    'zike_yang@163.com': ['杨自科'],
    '934875866@qq.com': ['陶同华'],
    '63459509@qq.com': ['黄竣宇'],
    '1254100507@qq.com': ['刘洋'],
    'luck9999@139.com': ['徐静皎'],
    '15990822775@139.com': ['张春'],
    '971823408@qq.com': ['沈丹'],
    'yindan2008@126.com': ['尹丹'],
    '492727853@qq.com': ['徐彦超'],
    '2534635086@qq.com': ['王宇轩'],
    '741048135@qq.com': ['王海港'],
    '471509768@qq.com': ['唐孟军'],
    '835843296@qq.com': ['王可欣'],
    '872039833@qq.com': ['员小林'],
    'irene.yu@aureright.com': ['余静'],
    'lixiaojing0120@163.com': ['李肖静']}

mails_test = {'bianzhiwei@iyoujia.com': ('天津', '重庆'),
              'wujiming@iyoujia.com': ('奥术大师'),
              'dt@iyoujia.com': ('西安'),
              }

mails_invest_test = {'bianzhiwei@iyoujia.com': ('王春霞', '赵灏', '谢翻生', '周振宇', '陈仁超', '马亚妮'),
                     'dt@iyoujia.com': ('数据', '王春霞'),
                     }

mails_city_home = {"yushengzhu@city-home.cn;liuzhe@city-home.cn": ["天津"],
                   "zhangsen@iyoujia.com;lichan@city-home.cn": ["广州"],
                   # "mozhengrong@city-home.cn": ["重庆", "成都"]
                   }

error_mail = 'dt@iyoujia.com;891915210@qq.com'
error_mobiles = '15910228878'

mails_shield_report = {
    'liupeiyu@city-home.cn': ['武汉', '长沙', '南宁', '桂林'],
    'lichan@city-home.cn': ['广州', '深圳', '三亚', '海口', '厦门', '珠海'],
    'wuqiang@city-home.cn': ['上海', '苏州', '杭州', '宁波', '绍兴'],
    'zhangsen@iyoujia.com': ['北京', '天津', '南京', '淮安', '扬州', '镇江', '合肥'],
    'mozhengrong@city-home.cn': ['重庆', '成都', '贵阳', '昆明', '南充', '凉山'],
    'zengxueqin@iyoujia.com': ['广州', '珠海'],
    'leixuelong@iyoujia.com': ['三亚', '海口'],
    'yangzhiqiang@iyoujia.com': ['厦门'],
    'zhangxu@city-home.cn': ['深圳'],
    'zhuanglinyi@city-home.cn': ['广州'],
    'gaoqinwen@city-home.cn': ['成都', '南充', '凉山'],
    'liuxi@iyoujia.com': ['成都'],
    'chenshiyu@city-home.cn': ['重庆'],
    'leiwei@city-home.cn': ['重庆'],
    'jianghong@city-home.cn': ['重庆'],
    'oumingsong@iyoujia.com': ['重庆'],
    'huxiaoyun@iyoujia.com': ['昆明'],
    'liaoguochun@city-home.cn': ['昆明'],
    'lizhenxing@iyoujia.com': ['太原'],
    'liumengfei@city-home.cn': ['西安'],
    'lichengli@city-home.cn': ['郑州'],
    'xixiongli@city-home.cn': ['青岛', '济南', '威海'],
    'zhangxiaohao@city-home.cn': ['青岛', '济南', '威海'],
    'wangyajun@city-home.cn': ['北京'],
    'liying2@city-home.cn': ['北京'],
    'muluyue@iyoujia.com': ['天津'],
    'kongyuepeng@iyoujia.com': ['南京'],
    'liuzhe@city-home.cn': ['天津'],
    'wangchao@city-home.cn': ['南京'],
    'fengxiaoqi@city-home.cn': ['南京', '合肥'],
    'chentianxian@iyoujia.com': ['南京'],
    'xukaiyang@city-home.cn': ['淮安', '扬州', '镇江'],
    'tongkelei@iyoujia.com': ['杭州'],
    'shenchuan@iyoujia.com': ['苏州'],
    'weidong@city-home.cn': ['苏州'],
    'leiyuxin@city-home.cn': ['上海'],

    'wangzhe@city-home.cn': ['杭州'],
    'liubingyou@city-home.cn': ['宁波', '绍兴'],
    'chensi@city-home.cn': ['武汉'],
    'chenshunming@iyoujia.com': ['武汉'],
    'wangxiaolong@city-home.cn': ['桂林'],
    'wangbin@city-home.cn': ['南宁', '长沙'],
    'liujie@city-home.cn': ['长沙'],
}
